#ifndef EDITORPROXY_H
#define EDITORPROXY_H

#include <QDeclarativeItem>

class QGraphicsProxyWidget;
class EditorWidget;

class EditorProxy : public QDeclarativeItem
{
    Q_OBJECT
public:
    explicit EditorProxy(QDeclarativeItem *parent = 0);
    virtual ~EditorProxy();
    EditorWidget *editorWidget() const { return m_editor; }

protected:
    virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
    virtual bool sceneEvent(QEvent *event);

public slots:
    QString imageFilePath(const QString &filename) const;

    void undo();
    void redo();

    void cut();
    void copy();
    void paste();

    void clear();
    bool load(const QString &file);
    bool save(const QString &file);

    bool searchPrevious(const QString &text);
    bool searchNext(const QString &text);

signals:
    void undoAvailable(bool available);
    void redoAvailable(bool available);
    void copyAvailable(bool available);

private:
    QGraphicsProxyWidget *m_proxyWidget;
    EditorWidget *m_editor;
    mutable QString m_imageDirectory;
    qreal m_totalScaleFactor;
    qreal m_scrollFactor;

    void addRecent(const QString &file);
};

#endif // EDITORPROXY_H
